define(function (require, exports, module) {
	
	//组合框组
	var NumberInputGroup=function(minNumberInputSelector,maxNumberInputSelector,reg){
		this.minNumber=null;
		this.maxNumber=null;
		

		
		this.actionName=""
		
		this.minNumberInputSelector=minNumberInputSelector
		this.maxNumberInputSelector=maxNumberInputSelector
		
		this.minNumber=$(this.minNumberInputSelector).get(0).value
		this.maxNumber=$(this.maxNumberInputSelector).get(0).value
		
		
		this.regExp=new RegExp("^([1-9][\\d]{0,11}|0)(\\.[\\d]{1,2})?$");
		if(reg!=""&&reg!=undefined&&reg!=null){
			try{
                this.regExp=new RegExp(reg);
			}catch(e){
				console.log(e);
			}
		}
		var self=this;
		var options={
			
		};
		
		$(this.minNumberInputSelector).bind("change",function(event){self.minNumberInputChangeHandle(event);})
		$(this.maxNumberInputSelector).bind("change",function(event){self.maxNumberInputChangeHandle(event);})
	}
	NumberInputGroup.prototype.checkNumber=function(checkName){
		//var minNumber,endValue
		this.minNumber=$(this.minNumberInputSelector).val()
		this.maxNumber=$(this.maxNumberInputSelector).val()
		
		//alert(minNumber+" "+endValue);
		if(this.minNumber!=null && this.maxNumber!=null && this.minNumber!="" && this.maxNumber!=""){
			if(parseFloat(this.minNumber) > parseFloat(this.maxNumber)){
				if(checkName=="minNumber"){
					alert("最小值不能大于最大值");
					this.minNumber=null;
					$(this.minNumberInputSelector).get(0).value=""
				}else{
					alert("最大值不能小于最小值");
					this.maxNumber=null;
					$(this.maxNumberInputSelector).get(0).value=""
				}
			};
		}
	}
	NumberInputGroup.prototype.setMinNumber=function(minNumber){
		this.minNumber=minNumber;
		this.checkNumber("minNumber");
	}
	NumberInputGroup.prototype.setMaxNumber=function(maxNumber){
		
		this.maxNumber=maxNumber;
		this.checkNumber("maxNumber");
	}
	NumberInputGroup.prototype.regExp=null;

    NumberInputGroup.prototype.minNumberInputChangeHandle = function (event) {
        var value = event.target.value
        if('' != value){
            if (this.regExp.test(value)) {
                this.setMinNumber(value);
            } else {
                alert("请填有效数字格式（最多输入12位整数2位小数）");
                event.target.value = "";
            }
		}

    }
    NumberInputGroup.prototype.maxNumberInputChangeHandle = function (event) {
        var value = event.target.value
		if('' != value){
            if (this.regExp.test(value)) {
                this.setMaxNumber(value);
            } else {
                alert("请填有效数字格式（最多输入12位整数2位小数）");
                event.target.value = "";
            }
		}

    }
	module.exports = NumberInputGroup;
})